<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class At_l_d_b extends CI_Controller {
	     public function __construct()
       {
            parent::__construct();
		$this->load->helper("html");
		$this->load->helper("url");
		$this->load->helper('form');
		$this->load->helper('date');
		$this->load->model("dv_model");
		$this->load->model("at_l_d_b_model");
		//$this->load->model("guest_comment_model");
		//$this->load->model("news_events_model");
		//$this->load->model("roomcottages_model");
		$this->load->helper(array('form', 'url'));
		$this->load->library('pagination');
		$this->load->database();
	}
	

	//START ------------------at---------------------
	function index()
	{
		$rownum= $this->uri->segment(3);
		$data["records1"] = $this->at_l_d_b_model->getPage(30,$rownum);
		$this->load->view('at_l_d_b_list_view',$data);
        
	}
	
/*function ddlistsort()
	{
	$search=$_POST['search'];
	$data["search"]=$search;
	//$data["list_at"]=$this->at_model->get_at($search,false);
	$data["list_at_l_d_b"]=$this->at_l_d_b_model->get_at2($search);
	$this->load->view('at_l_d_b_list_view',$data);
  }*/
function ddlistsort()
	{
	$sort=$_POST['sort'];
	$data["sort"]=$sort;
	//$data["list_at"]=$this->at_model->get_at($search,false);
	$data["list_at_l_d_b"]=$this->at_l_d_b_model->get_atsort($sort);
	$this->load->view('at_l_d_b_list_view',$data);
  }
function SearchDdlistsort()
	{
	$column_value=$_POST['column_value'];
	$data["column_value"]=$column_value;
	$data["list_at_l_d_b"]=$this->at_l_d_b_model->get_at2($_POST['search_value'],$column_value);
	$this->load->view('at_l_d_b_list_view',$data);
	}
  
	function view_at_l_d_b()
	{
		$data['title']="Administrator Page";
		$code = $this->uri->segment(3);
		$data["list_at_l_d_b"] = $this->at_l_d_b_model->getat_l_d_b_info($code);
		//$data["list_customers"] = $this->customers_model->getcustomers();
		$this->load->view('at_l_d_b_list_view',$data);
	}

	function add_at_l_d_b()
	{
		$data['title']="Administrator Page";
		$code = $this->uri->segment(3);
		$data["list_at_l_d_b"] = $this->at_l_d_b_model->getat_l_d_b_info($code);		
		$this->load->view('at_l_d_b_add_view',$data);
	}

	function p_getinfo()
	{		
		$info = $this->dv_model->getatInfoby_dv_company_name($_GET['dv_company_name']);			
		$this->output->set_content_type('application/json');
    	$this->output->set_output(json_encode($info));
	}

	function p_add_at_l_d_b()
	{
		$this->load->database();			
		$f_name =$_POST['txtf_name'];
		$dv_company_name =$_POST['dv_company_name'];
		$drop_off_city =$_POST['txtdrop_off_city'];
		$drop_off_state =$_POST['txtdrop_off_state'];
		$drop_off_date =$_POST['txtdrop_off_date'];
		$des_zone =$_POST['txtdes_zone'];	
		$rownum =$this->uri->segment(3);	
			$_sql="insert into at_new (f_name,dv_company_name,drop_off_city,drop_off_state,drop_off_date,des_zone)";
			$_sql.="values('$f_name','$dv_company_name','$drop_off_city','$drop_off_state','$drop_off_date','$des_zone')";
			$query = $this->db->query($_sql); 		
			$data["records1"] = $this->at_l_d_model->getPage(30,$rownum);
			$this->load->view('at_l_d_b_list_view',$data);			
	}

	function edit_at_l_d_b()
	{
 	    $code = $this->uri->segment(3);
		$data["info"] = $this->at_l_d_b_model->getat_l_d_b_info($code);	
		$this->load->view('at_l_d_b_edit_view',$data);
	}
	function p_edit_at()
	{
$this->load->database();
		$at_id =$_POST['hid_atid'];
		$f_name =$_POST['txtf_name'];
		$dv_company_name =$_POST['dv_company_name'];
		$drop_off_city =$_POST['txtdrop_off_city'];
		$drop_off_state =$_POST['txtdrop_off_state'];
		$drop_off_date =$_POST['txtdrop_off_date'];
		$des_zone =$_POST['txtdes_zone'];	
		$rownum =$this->uri->segment(3);
		//$select =$_POST['select'];				
			$query = $this->db->query("UPDATE at_new SET      
														  f_name='$f_name',
														  drop_off_city='$drop_off_city',
														  drop_off_state='$drop_off_state',														
														  drop_off_date='$drop_off_date',
														  des_zone='$des_zone' where at_id= $at_id"); 		
	
		$data["records1"] = $this->at_l_d_b_model->getPage(30,$rownum);
		$this->load->view('at_l_d_b_list_view',$data);		
	}

	function deletex()
	{
		$this->load->database();		
		$code = $this->uri->segment(3);
		$query = $this->db->query("delete from available_truck where at_id='$code'");
		$data["list_at_l_d_b"] = $this->at_l_d_b_model->get_all_at_l_d_b();	
		$this->load->view('at_l_d_b_list_view',$data);
		
	}
	
	
		function delete_at_l_d_b()
	{
		$at_id =$_POST['at_id'];
		$this->at_l_d_b_model->deleteinfo($at_id);
		$this->output->set_content_type('application/json');
    	$this->output->set_output(json_encode(array('msg'=>'ok')));
	}
	//END ------------------at---------------------
	function logout()

	{
		//$this->load->library('session');
		//$this->session->sess_destroy();
		session_start();
		session_destroy();
		//echo $_SESSION['Administrator_log'];
	//unset($_SESSION['Administrator_log']);
			//$data["newsresult"] = $this->at_model->dv_all_driver_vendor();
			$this->load->view('admin_view');
		}
}

?>